This R Script contains the code needed to replicate all analysis in the forthcoming manuscript "Forecasting Partisan Collective Accountability During the 2024 U.S. Elections" to be published as a part of the Symposium on Forecasting the 2024 U.S. Elections in PS: Political Science & Politics.
 
Note that this replication file assumes all source data files are saved in a folder called "Posted_Replication". Please place the following source data files into this folder prior to running the replication code. Note all figures and tables will saved to this folder.
 
The output of the PS_Forecasting_Analysis.R file is as follows and can be saved in the main replication directory:
 
Manuscript:
 
Figure 1: Presidential Approval & Incumbent Party Congressional Generic Percentage
Figure 2: Marginal Effect of Presidential Approval & Party Brands on Election Outcomes
Figure 3: Forecasting Model Out-of-Sample Predictions & Accuracy
Table 1: 2024 Presidential Popular Vote Prediction Over Presidential Approval Levels
Table 2: 2024 Presidential Electoral Vote Prediction Over Presidential Approval Level
Table 3: 2024 U.S. Senate Prediction Over Generic Ballot Levels
Table 4: 2024 U.S. House Prediction Over Generic Ballot Levels
 
 Appendix:
 
Table A1: Quarterly Descriptive Statistics, 1937-2024
Figure A1: Presidential Approval & Incumbent Party Congressional Generic Percentage
Figure A2: Correlation of Quarterly Presidential Approval & Incumbent Party Brand By President
Table A2: Quarterly OLS Models Predicting Incumbent Party Electoral Brand, 1937-2024
Table A3: Annual Descriptive Statistics, 1938-2022
Table A4: OLS Models Predicting Incumbent Party Popular Vote Percentage, 1940-2020
Table A5: OLS Models Predicting Incumbent Party Electoral Votes, 1940-2020
Table A6: OLS Models Predicting Incumbent Party U.S. Senate Seats, 1938-2022
Table A7: OLS Models Predicting Incumbent Party U.S. House Seats, 1938-2022
Figure A3: Marginal Effect of Presidential Approval on Outcomes By Election Type, 1940-2020
Table A8: Out of Sample Predictions for Incumbent Party Popular Vote Percentage, 1940-2020
Table A9: Out of Sample Predictions for Incumbent Party Electoral Votes, 1940-2020
Table A10: Out of Sample Predictions for Incumbent Party U.S. Senate Seats, 1938-2022
Table A11: Out of Sample Predictions for Incumbent Party U.S. House Seats, 1938-2022
 
Packages required for the analysis, please use the following code to install the packages prior to running the replication code:
 
install.packages(c(“readxl”, “marginaleffects”, “ggplot2”, “modelsummary”, “sandwich”, “zoo”, “DataCombine”, “plyr”, “broom”, “lmtest”))

Replication successful in R version 4.4.2 "Pile of Leaves" on a system running MacOS Sequoia 15.2